package com.hfdg.process.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfdg.process.mapper.TaskDataQueryMapper;
import com.hfdg.process.service.TaskDataService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class TaskDataServiceImpl implements TaskDataService {
@Autowired
    TaskDataQueryMapper taskDataQueryMapper;
    @Override
    public PageInfo listToDo(int offset, int limit, String orderBy, Map<String, Object> params) {
        if(null==orderBy|| StringUtils.isBlank(orderBy)){
            PageHelper.startPage((offset/limit)+1,limit);
        }else{
            PageHelper.startPage((offset/limit)+1,limit,orderBy);
        }
        PageInfo pageInfo =new PageInfo<>(taskDataQueryMapper.listTodo(params));
        return pageInfo;
    }

    @Override
    public PageInfo listDone(int offset, int limit, String orderBy, Map<String, Object> params) {
        if(null==orderBy|| StringUtils.isBlank(orderBy)){
            PageHelper.startPage((offset/limit)+1,limit);
        }else{
            PageHelper.startPage((offset/limit)+1,limit,orderBy);
        }
        PageInfo pageInfo =new PageInfo<>(taskDataQueryMapper.listDone(params));
        return pageInfo;
    }

    @Override
    public List<Map<String,Object>> listProcessComment(Map<String, Object> params) {
        return taskDataQueryMapper.listProcessComment(params);
    }
}
